package org.batatasframework.bytecode;

import org.batatasframework.bytecode.spi.AsmLoadable;
import org.springframework.asm.MethodVisitor;

public class ThisVariableAsminfo implements AsmLoadable{
	
	private final AsmMethodBody methodBody;
	private final ClassAsminfo owner;
	private final int thisVariable = 0;

	public ThisVariableAsminfo(AsmMethodBody methodBody, ClassAsminfo owner){
		this.methodBody = methodBody;
		this.owner = owner;
	}

	@Override
	public void load(MethodVisitor visitor, ClassAsminfo targetType) {
		visitor.visitVarInsn(owner.insnLoad(), thisVariable);
		targetType.cast(visitor, owner);
	}
	
	@Override
	public void load(MethodVisitor visitor) {
		visitor.visitVarInsn(owner.insnLoad(), thisVariable);
	}

	public AsmMethodBody getMethodBody() {
		return methodBody;
	}

}
